package com.lzh.java9;

import org.junit.Test;

import java.io.File;
import java.io.IOException;

/**
 * @author liuzhihao
 * @create 2021-02-23 14:17
 */
public class FileTest {

    @Test
    public void test() throws IOException {
        File file = new File("d:\\io\\a.txt");
        String parent = file.getParent();
        File file1 = new File(parent,"b.txt");

        if(file1.exists()){
            System.out.println("文件已存在");
        }else{
            file1.createNewFile();
            System.out.println("文件创建成功");
        }

    }

}
